﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace ConfigServices
{
    public class IniFileConfigService : IConfigService
    {

        public string FilePath { get; set; } = string.Empty;

        public string GetValue(string name)
        {
            var kv = File.ReadAllLines(FilePath)
                .Select(line => line.Split("="))
                .Select(strs => new { Name = strs[0], Value = strs[1] })
                .SingleOrDefault(kv => kv.Name == name);
            if (kv != null)
                return kv.Value;
            else
                return null;
        }
    }
}
